package signalprocessing;



import ikelib.drawTools;
import ikelib.wintime;


import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;

/**
 * @author Toshiharu Ikeda <ikeda.104@gmail.com>
 *
 */
public class PlotAxisTView extends PlotAxisT {

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	
	public PlotAxisTView(){
		setDirection(true);
		setAxisDivide(4,true,4,false);
	}
	@Override
	public void paintComponent(Graphics g){
		//super.paintComponent(g);
		Dimension dm = this.getSize();
		Graphics2D g2 = (Graphics2D)g;
		if(Col!=null){
			g2.setBackground(Col.ColorBackGround);
			g2.setColor(Col.ColorAxis);
		}
		g2.clearRect(0,0,dm.width,dm.height);

		//		g2.drawRect(10,10,dm.width-20,dm.height-20);
		//		g2.drawString("XAxisview" , 10, 20);
		Rectangle southrect = new Rectangle(0, 0 ,dm.width,  10);
		
		wintime xs = getViewStartTime();
		double span = getViewTimeSpanSec();		
	//	double xmin = xs.getValue();	// m
		//double xmax = xmin + span*1e3;
		
		int tick = getAxisDivide();
		String[] sl = new String[tick+1];
		for(int i=0;i<tick+1;i++){
			double delta=i* span/((double)tick);
			wintime wt = new wintime(xs);
			wt.inc_msec((int)(delta*1000));
			sl[i] =  wt.fmtmSec();
		}
		// 時刻と目盛を描画する
		drawAxis(g2,AxisPlacedBottom,southrect,tick,sl);
		// 日付を描画
		String date = xs.fmtDay();
		drawTools.drawText(g2, date, 0, 20, drawTools.POSITION_LEFT_TOP);
		
		if(TitleDisplay){
			Font f = g2.getFont();
			Font f2 = f.deriveFont(Font.BOLD);
			g2.setFont(f2);
			drawTools.drawText(g2, Title, dm.width/2, dm.height, drawTools.POSITION_CENTER_BOTTOM);
			g2.setFont(f);
		}
		
	}


}
